package com.android.djlmapp.adapter.my;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.djlmapp.R;
import com.android.djlmapp.model.my.JiaKuanInfo;
import com.bumptech.glide.Glide;

import org.refresh_view.pullrecyclerview.BaseRecyclerAdapter;
import org.refresh_view.pullrecyclerview.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

public class JiaKuanAdapter extends BaseRecyclerAdapter<JiaKuanInfo.DataBean> {
    private Context mContext;
    public JiaKuanAdapter(Context context) {
        super(context, R.layout.jiakuan_item, new ArrayList<>());
        mContext = context;
    }


    @Override
    protected void convert(BaseViewHolder holder, JiaKuanInfo.DataBean item) {
        ImageView img = holder.itemView.findViewById(R.id.jk_img);
        TextView name = holder.itemView.findViewById(R.id.jk_name);
        TextView time = holder.itemView.findViewById(R.id.jk_time);
        TextView money = holder.itemView.findViewById(R.id.jk_money);

//        Log.i("djlm-my: ",  item.getImg());

        img.setVisibility(View.VISIBLE);
        Glide.with(mContext)
                .load(item.getImg())
                .into(img);

        name.setText(item.getPay_name());

        time.setText(item.getAdddate()+ " " + item.getAddtime());

//        Log.i("djlm-my: getIs_ok",  item.getIs_ok());

        //加款
        if("1".equals(item.getIs_ok())){
            money.setTextColor(holder.itemView.getContext().getResources().getColor(R.color.jk_blue));
            money.setText("+"+item.getMoney());
        }else{
            money.setTextColor(holder.itemView.getContext().getResources().getColor(R.color.jk_grey));
            money.setText(item.getMoney());
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnItemClickListener.onItemClick(item);
            }
        });
    }


    public OnItemClickListener mOnItemClickListener;

    public interface OnItemClickListener {
        void onItemClick(JiaKuanInfo.DataBean item);
    }

    public void setOnItemClickListener(OnItemClickListener mOnItemClickLitener) {
        this.mOnItemClickListener = mOnItemClickLitener;
    }
}
